package entitygeneralizationcircle;

import org.eclipse.emf.ecore.EObject;

import org.eclipse.viatra2.emf.incquery.validation.runtime.Constraint;
import org.eclipse.viatra2.emf.incquery.validation.runtime.ValidationUtil;
import org.eclipse.viatra2.emf.incquery.runtime.api.impl.BaseGeneratedMatcherFactory;
import entitygeneralizationcircle.EntityGeneralizationCircleMatch;
import entitygeneralizationcircle.EntityGeneralizationCircleMatcherFactory;
import entitygeneralizationcircle.EntityGeneralizationCircleMatcher;

public class EntityGeneralizationCircleConstraint extends Constraint<EntityGeneralizationCircleMatch> {

	private EntityGeneralizationCircleMatcherFactory matcherFactory;

	public EntityGeneralizationCircleConstraint() {
		matcherFactory = new EntityGeneralizationCircleMatcherFactory();
	}

	@Override
	public String getMessage() {
		return "Entity $entity.name$ is involved in a generalization circle.";
	}

	@Override
	public EObject getLocationObject(EntityGeneralizationCircleMatch signature) {
		Object location = signature.get("entity");
		if(location instanceof EObject){
			return (EObject) location;
		}
		return null;
	}
	
	@Override
	public int getSeverity() {
		return ValidationUtil.getSeverity("error");
	}
	
	@Override
	public BaseGeneratedMatcherFactory<EntityGeneralizationCircleMatch, EntityGeneralizationCircleMatcher> getMatcherFactory() {
		return matcherFactory;
	}
}
